//package com.ruoyi.psi.base.warehouse.service;
//
//
//import com.ruoyi.psi.base.product.domain.BaseProduce;
//import com.ruoyi.psi.base.product.mapper.BaseProduceMapper;
//import com.ruoyi.psi.base.product.service.BaseProduceServiceImpl;
//import com.ruoyi.psi.base.producealarm.domain.ProduceAlarm;
//import com.ruoyi.psi.base.producealarm.mapper.ProduceAlarmMapper;
//import com.ruoyi.psi.base.warehouse.domain.BaseWarehouse;
//import com.ruoyi.psi.base.warehouse.mapper.BaseWarehouseMapper;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.List;
//
///**
// * 仓库
// * 业务层处理
// * @author Drj 2021/6/28
// */
//@Service
//public class BaseWarehouseServiceImpl implements IBaseWarehouseService{
//    @Autowired
//    private BaseProduceMapper baseProduceMapper;
//    @Autowired
//    private BaseWarehouseMapper baseWarehouseMapper;
//    @Autowired
//    private ProduceAlarmMapper produceAlarmMapper;
//    @Autowired
//    private BaseProduceServiceImpl baseProduceService;
//    /**
//     * 根据条件查询仓库
//     *
//     * @param baseWarehouse 仓库信息
//     * @return 仓库集合
//     */
//    @Override
//    public List<BaseWarehouse> selectBaseWarehouseList(BaseWarehouse baseWarehouse) {
//        return baseWarehouseMapper.selectBaseWarehouseList(baseWarehouse);
//    }
//
//    /**
//     * 根据id查询仓库
//     *
//     * @param warehouseId 仓库编号
//     * @return 仓库
//     */
//    @Override
//    public BaseWarehouse selectBaseWarehouseById(String warehouseId) {
//        return baseWarehouseMapper.selectBaseWarehouseById(warehouseId);
//    }
//
//    /**
//     * 获取对应仓库产品信息仓库编号
//     *
//     * @param warehouseId
//     * @return
//     */
//    @Override
//    public List<BaseProduce> getProduce(String warehouseId) {
//        List<BaseProduce> produceList = baseProduceMapper.selectBaseProduceList(new BaseProduce());
//        for (int i = 0; i < produceList.size(); ) {
//            Double tempNum = baseProduceService.getProduceNumTotal(warehouseId,produceList.get(i).getProduceId());
//            if (tempNum <= 0){
//                produceList.remove(i);
//            }else{
//                produceList.get(i).setProduceNumber(baseProduceService.getProduceNumTotal(warehouseId,produceList.get(i).getProduceId()));
//                i++;
//            }
//
//        }
//
//        return produceList;
//    }
//
//    /**
//     * 新增仓库
//     *
//     * @param baseWarehouse 仓库信息
//     * @return 结果
//     */
//    @Override
//    @Transactional(rollbackFor = Exception.class)
//    public int insertBaseWarehouse(BaseWarehouse baseWarehouse) throws Exception{
//        if (baseWarehouseMapper.selectBaseWarehouseById(baseWarehouse.getWarehouseId()) != null){
//            return 0;
//        }
//        baseWarehouseMapper.insertBaseWarehouse(baseWarehouse);
//        List<BaseProduce>baseProduceList = baseProduceMapper.selectBaseProduceList(new BaseProduce());
//        for (int i = 0; i < baseProduceList.size(); i++) {
//            ProduceAlarm produceAlarm = new ProduceAlarm(baseProduceList.get(i).getProduceId(),baseWarehouse.getWarehouseId());
//            produceAlarmMapper.insertProduceAlarm(produceAlarm);
//        }
//        return 1;
//    }
//
//    /**
//     * 修改仓库数据
//     *
//     * @param baseWarehouse 仓库信息
//     * @return 结果
//     */
//    @Override
//    public int updateBaseWarehouse(BaseWarehouse baseWarehouse) {
//        if (baseWarehouseMapper.selectBaseWarehouseById(baseWarehouse.getWarehouseId()) == null){
//            return 0;
//        }
//        return baseWarehouseMapper.updateBaseWarehouse(baseWarehouse);
//    }
//
//    /**
//     * 删除功能
//     * 更新对应仓库删除标志
//     *
//     * @param baseWarehouse 仓库信息
//     * @return 结果
//     */
//    @Override
//    public int updateBaseWarehouseDeleteFlag(BaseWarehouse baseWarehouse) {
//        return baseWarehouseMapper.updateBaseWarehouseDeleteFlag(baseWarehouse);
//    }
//}
